//
//  WHYStatus.swift
//  WHYWeibo-1.0
//
//  Created by 王洪运 on 15/11/25.
//  Copyright © 2015年 王洪运. All rights reserved.
//

import UIKit

class WHYStatus: NSObject {

 /// 创建时间
    var created_at: String?
 /// 微博ID
    var id: Int = 0
 /// 微博内容
    var text:String?
 /// 微博来源
    var source: String? {
        didSet {
            source = source?.href()?.source
        }
    }
/// 用户模型
    var user: WHYUser?
/// 缩略图片字典数组地址  [字典]?
    var pic_urls: [[String: String]]?
/// 被转发的原微博信息字段
    var retweeted_status: WHYStatus?
    
//    MARK: - 构造函数
    init(dict: [String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict);
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        
        if key == "user" {
            if let dict = value as? [String: AnyObject] {
                user = WHYUser(dict: dict)
            }
            return
        }
        
        if key == "retweeted_status" {
            if let dict = value as? [String: AnyObject] {
                retweeted_status = WHYStatus(dict: dict)
            }
            return
        }
        
        super.setValue(value, forKey: key)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {    }
    
    override var description: String {
        let keys = ["created_at", "id", "text", "source", "user", "pic_urls","thumbnailUrls", "retweeted_status"]
        
        return dictionaryWithValuesForKeys(keys).description
    }
    
    
    
    
}
